package com.example.wechattakeaway.controller;

import com.example.wechattakeaway.accessctro.RolePermission;
import com.example.wechattakeaway.form.mermenuform.InsertMerMenuForm;
import com.example.wechattakeaway.form.mermenuform.UpdateMerMenuForm;
import com.example.wechattakeaway.service.MerMenuService;
import com.example.wechattakeaway.vo.ResultVO;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@Slf4j
@RestController
@RequestMapping("/MerMenuController")
@Api(tags = "菜单信息管理模块")
public class MerMenuController {
    @Autowired
    MerMenuService merMenuService;

    @ApiOperation(value = "添加菜单信息",notes = "商家web端")
    @PostMapping("/insertMerMenu")
    public ResultVO insertMerMenu(InsertMerMenuForm insertMerMenuForm){

        return merMenuService.insertMerMenu(insertMerMenuForm);
    }

    @ApiOperation(value = "编辑菜单信息",notes = "商家web端")
    @PostMapping("/updateMerMenu")
    public ResultVO updateMerMenu(UpdateMerMenuForm updateMerMenuForm){

        return merMenuService.updateMerMenu(updateMerMenuForm);
    }

    @ApiOperation(value = "根据菜单id查询对应菜单",notes = "小程序端以及商家web端")
    @ApiImplicitParam(name="menuId",value="菜单id",example = "1",dataType = "Integer",paramType = "query")
    @GetMapping("/selectMenuById")
    public ResultVO selectMenuById(@RequestParam("menuId") Integer menuId){

        return merMenuService.selectMenuById(menuId);
    }

    @ApiOperation(value = "根据商家id查询对应菜单列表（分页）",notes = "商家web端")
    @ApiImplicitParam(name="merchantId",value="商家id",example = "1",dataType = "Integer",paramType = "query")
    @GetMapping("/selectMenuByMerchantId")
    public ResultVO selectMenuByMerchantId(@RequestParam("pageNum") Integer pageNum,@RequestParam("merchantId") Integer merchantId){

        return merMenuService.selectMenuByMerchantId(pageNum,merchantId);
    }


    @ApiOperation(value = "根据商家id查询对应菜单列表",notes = "小程序端")
    @ApiImplicitParam(name="merchantId",value="商家id",example = "1",dataType = "Integer",paramType = "query")
    @GetMapping("/selectMenuByMerId")
    public ResultVO selectMenuByMerId(@RequestParam("merchantId") Integer merchantId){

        return merMenuService.selectMenuByMerId(merchantId);
    }


    @ApiOperation(value = "根据菜单id删除菜单",notes = "商家web端")
    @PostMapping("/deleteMerMenu")
    public ResultVO deleteMerMenu(Integer menuId){
        return merMenuService.deleteMerMenu(menuId);
    }


}
